package com.asia5b.a5mall.middleware.model.shop

import android.text.TextUtils
import com.asia5b.a5mall.middleware.model.base.BaseModel
import com.asia5b.a5mall.middleware.utils.WTimeUtils
import com.asia5b.a5mall.middleware.utils.dddLog

/**
 * Created by zhangyuncai on 2020/6/29.
 */
class ApplyShopResModel : BaseModel() {


    //银行开户名
    var bank_account_name = ""

    //开户银行所在省
    var bank_city = ""

    //开户银行所在省id
    var bank_city_id = ""

    //开户银行所在市
    var bank_county = ""

    //开户银行所在市id
    var bank_county_id = ""

    //开户银行许可证电子版
    var bank_img = ""

    //开户银行支行名称
    var bank_name = ""

    //银行开户账号
    var bank_number = ""

    //开户银行所在国家
    var bank_province = ""

    //开户银行所在国家ID
    var bank_province_id = ""

    //开户银行所在镇
    var bank_town = ""

    //开户银行所在镇id
    var bank_town_id = ""

    //支付宝收款账户
    var beneficiary = ""

    //支付宝开户名
    var beneficiary_real_name = ""

    //组织机构电子版
    var code_img = ""

    //公司地址
    var company_address = ""
    //公司邮箱
    var company_email = ""

    //公司名称
    var company_name = ""
    //公司电话
    var company_phone = ""

    //是否允许开具电子普通发票 0：否，1：是
    var elec_receipt_status = ""

    //员工总数
    var employee_num = ""

    //成立日期,1577808000
    var establish_date = ""

    //店铺经营类目
    var goods_management_category = ""
    //店铺商品数
    var goods_num = ""

    //货品预警数
    var goods_warning_count = ""

    //法人身份证
    var legal_id = ""

    //法人身份证照片
    var legal_img = ""

    //法人姓名
    var legal_name = ""

    //营业执照有效期结束
    var licence_end = ""

    //营业执照电子版
    var licence_img = ""

    //营业执照有效期开始
    var licence_start = ""

    //营业执照详细地址
    var license_add = ""

    //营业执照所在市
    var license_city = ""

    //营业执照所在市id
    var license_city_id = ""

    //营业执照所在县
    var license_county = ""

    //营业执照所在县id
    var license_county_id = ""

    //营业执照号
    var license_num = ""

    //营业执照所在省
    var license_province = ""

    //营业执照所在省id
    var license_province_id = ""

    //营业执照所在镇
    var license_town = ""

    //营业执照所在镇id
    var license_town_id = ""

    //联系人姓名
    var link_name = ""

    //联系人电话
    var link_phone = ""

    //会员Id
    var member_id = ""

    //会员名称
    var member_name = ""

    //是否允许开具增值税普通发票 0：否，1：是
    var ordin_receipt_status = ""

    //组织机构代码
    var organization_code = ""

    //注册资金
    var reg_money = ""

    //法定经营范围
    var scope = ""

    //是否自营 1:是 0:否
    var self_operated = ""

    //结算方式:0:月结,1:票结
    var settlement_method = ""

    //店铺详细地址
    var shop_add = ""

    //店铺横幅
    var shop_banner = ""

    //店铺所在市
    var shop_city = ""

    //店铺所在市id
    var shop_city_id = ""

    //店铺收藏数
    var shop_collect = ""

    //店铺佣金比例
    var shop_commission = ""

    //店铺所在县
    var shop_county = ""

    //店铺所在县id
    var shop_county_id = ""

    //店铺创建时间
    var shop_createtime = ""

    //店铺信用
    var shop_credit = ""

    //发货速度分数
    var shop_delivery_credit = ""

    var shop_delivery_credit_text = ""

    //店铺简介
    var shop_desc = ""

    //店铺描述相符度
    var shop_description_credit = ""

    var shop_description_credit_text = ""

    //店铺状态 APPLYING
    var shop_disable = ""

    //店铺关闭时间
    var shop_endtime = ""

    //店铺Id
    var shop_id = ""

    //店铺等级
    var shop_level = ""

    //店铺等级申请
    var shop_level_apply = ""

    //店铺logo
    var shop_logo = ""

    //店铺名称
    var shop_name = ""

    //店铺好评率
    var shop_praise_rate = ""

    //店铺所在省
    var shop_province = ""

    //店铺所在省id
    var shop_province_id = ""

    //店铺客服qq
    var shop_qq = ""

    //是否推荐
    var shop_recommend = ""

    //服务态度分数
    var shop_service_credit = ""

    var shop_service_credit_text = ""

    //店铺主题模版路径
    var shop_theme_path = ""

    //店铺主题id
    var shop_themeid = ""

    //店铺所在镇
    var shop_town = ""

    //店铺所在镇id
    var shop_town_id = ""

    //申请开店进度：1,2,3,4
    var step = ""

    //店铺相册已用存储量
    var store_space_capacity = ""

    //是否允许开具增值税专用发票 0：否，1：是
    var tax_receipt_status = ""

    //税务登记证书
    var taxes_certificate_img = ""

    //税务登记证号
    var taxes_certificate_num = ""

    //纳税人识别号
    var taxes_distinguish_num = ""

    //一般纳税人证明电子版
    var taxes_img = ""

    //sku列表
    var verify_log_list = ""

    //wap店铺主题
    var wap_theme_path = ""

    //店铺主题id
    var wap_themeid = ""


    /**
     * 防止服务器返回null字段
     */
    fun checkNull() {
        for (declaredField in this::class.java.declaredFields) {
            val text = "${declaredField.get(this)}"
            if (TextUtils.equals(text, "null")) {
                declaredField.set(this, "")
            }
        }
    }

    /**
     * @param countryName 国家
     * @param provinceName 省
     * @param cityName 市
     * @param townName 区
     */
    fun concatAddress(countryName: String, provinceName: String, cityName: String, townName: String): String {
        val stringBuffer = StringBuffer()
        if (!TextUtils.isEmpty(countryName)) {
            stringBuffer.append("${countryName} ")
        }
        if (!TextUtils.isEmpty(provinceName)) {
            stringBuffer.append("${provinceName} ")
        }
        if (!TextUtils.isEmpty(cityName)) {
            stringBuffer.append("${cityName} ")
        }
        if (!TextUtils.isEmpty(townName)) {
            stringBuffer.append("${townName} ")
        }
        return stringBuffer.toString().trim()
    }


    /**
     * 国家/省/市/区中的最后一级regionId
     * @param countryName 国家
     * @param provinceId 省
     * @param cityId 市
     * @param townId 区
     */
    fun getLastRegionId(countryId: String, provinceId: String, cityId: String, townId: String): String {
        if (!TextUtils.isEmpty(townId)) {
            return townId
        } else if (!TextUtils.isEmpty(cityId)) {
            return cityId
        } else if (!TextUtils.isEmpty(provinceId)) {
            return provinceId
        } else if (!TextUtils.isEmpty(countryId)) {
            return countryId
        }
        return ""
    }


    //开户行拼接地址
    val bankConcatName: String
        get() {
            return concatAddress(bank_province, bank_city, bank_county, bank_town)
        }

    //开户行所在地
    val bankRegionId: String
        get() {
            return getLastRegionId(bank_province_id, bank_city_id, bank_county_id, bank_town_id)
        }
    var bank_region = ""


    //营业执照拼接地址
    val licenseConcatName: String
        get() {
            return concatAddress(license_province, license_city, license_county, license_town)
        }

    //营业执照所在地
    val licenseRegionId: String
        get() {
            return getLastRegionId(license_province_id, license_city_id, license_county_id, license_town_id)
        }
    var license_region = ""

    //店铺拼接地址
    val shopConcatName: String
        get() {
            return concatAddress(shop_province, shop_city, shop_county, shop_town)
        }

    //店铺所在地
    val shopRegionId: String
        get() {
            return getLastRegionId(shop_province_id, shop_city_id, shop_county_id, shop_town_id)
        }
    var shop_region = ""
}
